/**
 * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
 */
package com.z100h.supplychain.statistics.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.jeeplus.core.persistence.Page;
import com.jeeplus.core.service.CrudService;
import com.jeeplus.modules.sys.utils.UserUtils;
import com.z100h.supplychain.sku.entity.SkuAmount;
import com.z100h.supplychain.statistics.entity.RealtimeResourceAmount;
import com.z100h.supplychain.statistics.entity.StatRealtimeResource;
import com.z100h.supplychain.statistics.mapper.StatRealtimeResourceMapper;

/**
 * 成品库资源Service
 * @author fyh
 * @version 2019-02-14
 */
@Service
@Transactional(readOnly = true)
public class StatRealtimeResourceService extends CrudService<StatRealtimeResourceMapper, StatRealtimeResource> {

	@Autowired
	private StatRealtimeResourceMapper realtimeResourceMapper;

	@Override
	public StatRealtimeResource get(String id) {
		return super.get(id);
	}

	@Override
	public List<StatRealtimeResource> findList(StatRealtimeResource statRealtimeResource) {
		return super.findList(statRealtimeResource);
	}

	@Override
	public Page<StatRealtimeResource> findPage(Page<StatRealtimeResource> page,
			StatRealtimeResource statRealtimeResource) {
		return super.findPage(page, statRealtimeResource);
	}

	@Override
	@Transactional(readOnly = false)
	public void save(StatRealtimeResource statRealtimeResource) {
		super.save(statRealtimeResource);
	}

	@Override
	@Transactional(readOnly = false)
	public void delete(StatRealtimeResource statRealtimeResource) {
		super.delete(statRealtimeResource);
	}

	/**
	 * 
	 * 实时资源数量汇总
	 * 
	 * @param compnayId
	 * @return
	 * @author: Fyh - 1009173473@qq.com 
	 * @date: Created on 2020年7月7日 上午10:11:31
	 */
	public Page<RealtimeResourceAmount> findRealtimeResourceAmount(RealtimeResourceAmount realtimeResourceAmount,
			Page<RealtimeResourceAmount> page) {
		realtimeResourceAmount.setCompanyId(UserUtils.getUser().getCompanyId());
		realtimeResourceAmount.setPage(page);
		page.setList(realtimeResourceMapper.findRealtimeResourceAmount(realtimeResourceAmount));
		return page;
	}

	/**
	 * 
	 * 查找需要报损的资源码
	 * 
	 * @param skus
	 * @return
	 * @author: Fyh - 1009173473@qq.com 
	 * @date: Created on 2020年7月7日 上午10:22:17
	 */
	public List<String> findResourceIds(SkuAmount skuAmount, String companyId) {
		return realtimeResourceMapper.findResourceIds(skuAmount, companyId);
	}

}